#!/bin/sh

netstat -nltup | grep -P "(${1}\s+0\s+0\s+0(\.0){3}:$2\D)|(${1}6\s+0\s+0\s:::$2\D)" 
portcount=$(netstat -nltup | grep -P "(${1}\s+0\s+0\s+0(\.0){3}:$2\D)|(${1}6\s+0\s+0\s:::$2\D)"  | wc -l)
echo portcount=${portcount}
if [ ${portcount} -gt 0 ] 
then
   echo ok
   exit 0
else
   echo notexists
   exit 1
fi